package com.example.shop.goods.dao;

import com.example.shop.goods.dto.CommentsReply;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentsReplyDao {
    public static final String ALL_FIELDS_SQL =
            " reply_comments_id,reply_comments_user_id,comments_user_id,reply_content ";

    @Results(id = "CommentsReplyResultMap",value ={
            @Result(column = "reply_comments_user_id",property = "replyCommentsUser",
                    one = @One(select = "com.example.shop.user.dao.UserBriefInfoDao.selectById")),
            @Result(column = "comments_user_id",property = "commentsUser",
                    one = @One(select = "com.example.shop.user.dao.UserBriefInfoDao.selectById")),
    })
    @Select("select " + ALL_FIELDS_SQL +
            "from r_evaluation_comments_reply " +
            "where evaluation_id = ${evaluationId} " +
            "limit ${beginOffset},${pageSize} ")
    List<CommentsReply> selectPageByEvaluationId(@Param("evaluationId") Long evaluationId, @Param("beginOffset")int beginOffset, @Param("pageSize")int pageSize);

    @ResultMap("CommentsReplyResultMap")
    @Select("select " + ALL_FIELDS_SQL +
            "from r_evaluation_comments_reply " +
            "where evaluation_id = ${evaluationId} ")
    List<CommentsReply> selectByEvaluationId(Long evaluationId);

    @ResultMap("CommentsReplyResultMap")
    @Select("select "+ ALL_FIELDS_SQL +
            "from r_evaluation_comments_reply " +
            "where reply_comments_id = ${replyCommentsId} ")
    CommentsReply selectByReplyCommentsId(Long replyCommentsId);

}
